//
//  PublicMacro.h
//  XWKitDemo
//
//  Created by xiaowuxiaowu on 16/4/13.
//  Copyright © 2016年 xiaowuxiaowu. All rights reserved.
//

#ifndef PublicMacro_h
#define PublicMacro_h


#define kNSUserDefaultsCatesName @"kNSUserDefaultsCatesName" //分类
#define kNSUserDefaultsTagsName @"kNSUserDefaultsTagsName" //标签

#define kNotificationCenterLoginSccuess @"kNotificationCenterLoginSccuess" //登录成功通知
#define kNotificationPushMaking @"kNotificationPushMaking" //跳入制作
#define UNImagePath(name)  [NSString stringWithFormat:@"%@%@",BaseUrl,name]


#define AppShareAppDelegate (AppDelegate*)[[UIApplication sharedApplication]delegate]

#define IS_IPAD_DEVICE      ([(NSString *)[UIDevice currentDevice].model hasPrefix:@"iPad"])
#define IPHONE_HEIGHT      [[UIScreen mainScreen] bounds].size.height  /**-> 整屏高度 */
#define IPHONE_WIDTH       [[UIScreen mainScreen] bounds].size.width   /**-> 整屏宽度 */
#define Tabar_hight 50

#define kMaxRequestSize 15

//获取系统版本

#define IOS_VERSION [[[UIDevice currentDevice] systemVersion] floatValue]

// 加载图片
#define IMAGE_PNG(NAME)          [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:(NAME) ofType:@"png"]]
#define IMAGE_JPG(NAME)          [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:(NAME) ofType:@"jpg"]]
#define IMAGE_TEXT(NAME, EXT)        [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:(NAME) ofType:(EXT)]]

#define ImageNamed(_pointer) [UIImage imageNamed:_pointer]
#define WEAKSELF typeof(self) __weak weakSelf = self
#define STRONGSELF typeof(weakSelf) __strong strongSelf = weakSelf

//#define defaultUrl urlNamed(@"http://www.liriver.com.cn/img/2012329164910.jpg")?imageView2/1/w/300/h/300
//http://oq5bsj7c9.bkt.clouddn.com/nanji_mp4.mp4?vframe/jpg/offset/1/w/480/h/360
#define defaultUrl urlNamed(@"http://img2.soyoung.com/upload/20171020/6/20171020225703981.jpg")

#define kVideo_Placeholder_Url_w(url,w)  [NSString stringWithFormat:@"%@?vframe/jpg/offset/0/w/%d",url,w]
#define kVideo_Placeholder_Url(url)  [NSString stringWithFormat:@"%@?vframe/jpg/offset/0",url]

#define defaultLogo  ImageNamed(@"login_wx_bg")
#define Tripvi_avtor ImageNamed(@"TP_login_header_none_icon")
#define big_defaultLogo ImageNamed(@"login_wx_bg")
#define kTemplate_placeholder ImageNamed(@"Template_placeholder")

#define urlNamed(name) [NSURL URLWithString:name]
#define urlFileNamed(name) [NSURL fileURLWithPath:name]
#define kGetMediaUrl(name) [NSString stringWithFormat:@"http://qu.52charming.com/%@",name]

#define urlNamedWithW(name,w) [NSURL URLWithString:[NSString stringWithFormat:@"%@?imageView2/1/w/%ld",name,w]]
#define IMAGEBaseUrlNamed(name) [NSURL URLWithString:[NSString stringWithFormat:@"%@%@",IMGBaseUrl,name]]

#define kIntegerToString(ints)  [NSString stringWithFormat:@"%ld",ints]

#define IOS7_TOP_Y ( [UIApplication sharedApplication].statusBarFrame.size.height + 44.0)
#define IOS7 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) // 判断是否是IOS7的系统
#define IOS8 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) // 判断是否是IOS7的系统
#define IOS10 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 10.0) // 判断是否是IOS7的系统
#define IOS11 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 11.0) // 判断是否是IOS7的系统

#define HeightScaleSize(x) ((IPHONE_HEIGHT/480.0)*x)  //按高度比例缩放  以4为准
#define WidthScaleSize(x) (((x)/320.0)*MIN(IPHONE_WIDTH, IPHONE_HEIGHT))  //按宽带比例缩放 4为准

//适配系数
#define KScreenScalewidth ([UIScreen mainScreen].bounds.size.width/320.0f)
#define KScreenScaleheight ([UIScreen mainScreen].bounds.size.height/480.0f)



/** ->View 圆角和加边框 */
#define ViewBorderRadius(View, Radius, Width, Color)\
\
[View.layer setCornerRadius:(Radius)];\
[View.layer setMasksToBounds:YES];\
[View.layer setBorderWidth:(Width)];\
[View.layer setBorderColor:[Color CGColor]]

/** ->View 圆角 */
#define ViewRadius(View, Radius)\
\
[View.layer setCornerRadius:(Radius)];\
[View.layer setMasksToBounds:YES]


// 当前语言
#define CURRENTLANGUAGE         ([[NSLocale preferredLanguages] objectAtIndex:0])
#define kTPMLingWaiMedium_SC  @"HanziPenSC-W3"//@"MLingWaiMedium-SC"  //凌慧字体
// 本地化字符串
/** NSLocalizedString宏做的其实就是在当前bundle中查找资源文件名“Localizable.strings”(参数:键＋注释) */
#define LocalString(x, ...)     NSLocalizedString(x, nil)
/** NSLocalizedStringFromTable宏做的其实就是在当前bundle中查找资源文件名“xxx.strings”(参数:键＋文件名＋注释) */
#define AppLocalString(x, ...)  NSLocalizedStringFromTable(x, @"TP", nil)

#define  fontSystemOfSize(fone) [UIFont systemFontOfSize:fone]


// 一天的秒数
#define SecondsOfDay            (24.f * 60.f * 60.f)
// 秒数
#define Seconds(Days)           (SecondsOfDay * (Days))
// 一天的毫秒数
#define MillisecondsOfDay       (SecondsOfDay * 1000.f)
// 毫秒数
#define Milliseconds(Days)      (SecondsOfDay * 1000.f * (Days))


// app 信息
#define APP_STORE_URL       @"itms-apps://itunes.apple.com/us/app/xiong-zhao/id1020593660?l=zh&ls=1&mt=8"
#define APP_STORE_STRING @"https://itunes.apple.com/app/id1254816069?code="
#define APP_STORE_INFO_URL  @"https://itunes.apple.com/cn/lookup?id=1020593660"
#define VERSION             [[[NSBundle mainBundle] infoDictionary] valueForKey:@"CFBundleShortVersionString"]


// 自定义NSLog,在debug模式下打印，在release模式下取消一切NSLog
#ifdef DEBUG
#define DLog(FORMAT, ...) fprintf(stderr,"%s:%d\t%s\n",[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
#else
#define DLog(FORMAT, ...) nil
#endif


//检测block 是否存在
#define BLOCK_EXEC(block, ...) if (block) { block(__VA_ARGS__); };

#endif /* PublicMacro_h */
